package utils.https;

import java.net.URLEncoder;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HttpUtils {
	
	public static String map2MethodGetParams(Map<String, Object> map) throws Exception{
		StringBuffer sb = new StringBuffer();
		sb.append("?");
		for (String keys : map.keySet()) {
			String value = map.get(keys)+"";
	        Pattern p=Pattern.compile("[\u4e00-\u9fa5]"); 
	        Matcher m=p.matcher(value); 
	        if(m.find()){ 
	        	value = URLEncoder.encode(value,"UTF-8");
	        	sb.append(keys+"="+value+"&");
			}else{
				sb.append(keys+"="+value+"&");
			}
		}
		return sb.toString();
	}
	
	
	
	

}
